package com.gopay.common.constants;

/**
 * Yes/No常量
 * 
 * @YnFlag.java
 * @author zhanglei
 * @2013-8-8 下午2:02:12 www.gopay.com.cn Inc.All rights reserved.
 */
public enum YnFlag {
    /** y: yes */
    y("y"),
    /** n: no */
    n("n");

    public final String code;

    YnFlag(String code) {
        this.code = code;
    }

    /**
     * 根据枚举类型的字符串值 获取 相应的枚举变量
     */
    public static YnFlag get(String str) {
        YnFlag[] cs = YnFlag.class.getEnumConstants();
        for (YnFlag c : cs) {
            if (c.code.equals(str)){
                return c;
            }
        }
        throw new RuntimeException(" wrong " + YnFlag.class.getSimpleName() + " string code! " + str);
    }
}
